<template>
	<view class="uni-page-body">
		<text class="drop-out" @click="dropout">退出</text>
		<view class="content">
			<view class="title content-B" >
				<view> 
					<image class="logo" src="../../static/zsylogo2.png"/>	
				</view>
				<view class="title-text">采气工艺移动端监测平台</view>
				<!-- <text class="drop-out">退出</text> -->
			</view>
		</view>	
		
		<view class="content">	
			<view class="content-B uni-yj">
				<view class="flex-item-A content">
					<view class="uni-text1">所有井数</view>
					<view class="uni-text2" @click="allwell">{{wellNumber}}</view>
				</view>
				
				<view class="flex-item-B content">
					<view class="uni-text1">告警信息</view>
					<view class="uni-text3" @click="warning">{{warningNumber}}</view>
				</view>	
			</view>
		</view>	
		<view class="content">		
			<view class="uni-list-cell">
				<view class="uni-list-cell-left">
					所属单位
				</view>
					<view class="example-body uni-list-cell-db">
						<uni-combox  :candidates="unit" :value="city" @click="dwChange" >
						</uni-combox>
					</view>
			</view>	
			
			<view class="uni-list-cell">
				<view class="uni-list-cell-left">
					平台
				</view>
				<view class="uni-list-cell-db">
					<view class="example-body">
						<uni-combox  :candidates="ptList" :value="city2" @click="ptChange" >
						</uni-combox>
					</view>
				</view>
			</view>
						<view class="uni-list-cell">
							<view class="uni-list-cell-left">
								井号
							</view>
							<view class="uni-list-cell-db" >
								<input class="text-input"  @input="inputWell" :value="wellname"/>
							</view>
						</view>
						
						<view class="uni-botton1"></view>
					</view>
					
					<view class="content">
						<view class="uni-list-cell">
							<view class="dj-A"></view>
							<view class="uni-name">井号</view>
							<view class="uni-names2">单位</view>
							<view class="uni-names4">气井类型</view>
							<view class="uni-names3">通信状态</view>
						</view>
					</view>
					<!-- <view class="content">
						<view v-for="(item,i) in _self.texts" class="uni-dj-text ">
							<navigator :url="'../chart/zschart?well_id='+item.orgId+'&well_name='+item.name" class="content-B">
								<view class="uni-example">{{item.name}}</view>
							</navigator>
						</view>
					</view> -->
					<!-- 滚轮 -->
					<view>
						<scroll-view  scroll-y="true" class="scroll-Y" >
										<view v-for="(item,i) in _self.texts" class="uni-dj-text ">
											<navigator :url="'../chart/singleWellManagement?well_id='+item.orgId+'&well_name='+item.name+'&dictName='+item.dictName" class="content-B">
												<view class="uni-example">{{item.name}}</view>
												<view class="uni-example1">{{item.orgName}}</view>
												<view class="uni-example2">{{item.dictName}}</view>
												<view class="txzc22" v-if="item.status===0"></view>
												<view class="txbzc22" v-else="item.status===1"></view>
											</navigator>
										</view>
						</scroll-view>
					</view>
		</view>
	</view>
</template>
<script>
	var _self ;
	
	export default {
		data() {
			return {
				searchValue2:{
					dwId:'',
					jmjh:'',
					ptId:'',
					cjId:'',
					pylx:'82640297-49ba-4042-86a4-a70e6d8a1372',
				},
				platform: [{tname:""}],
				unit: [],
				ptList: [],
				wellList: [],
				searchValue:{
					orgId: '',
					ptId: '',
					wellId: '',
					gylx:'82640297-49ba-4042-86a4-a70e6d8a1372'
				},
				indexUnit: 0,
				index: 0,
				texts: [],
				wellNumber: 0,
				warningNumber: 0,
				wellname:'',
				ptJudeg:false,
				headerUrl:{
					intranet:'http:/'+'/'+'10.89.67.239:',
					local:'http:/'+'/'+'127.0.0.1:',
				},
				city: '',
				city2: '',
				unitss:[],
			}
		},
		
		onLoad() {
			_self=this;
			this.getUnit();
			//this.getPtList();
			//加载井的
			this.getWellList();
			//加载有调派服务的数据
			this.getWellList1();
			//加载一共多少井的
			this.getWellNumber();
			//加载一共多少告警的
			this.getWarningNumber();
		},
		
		methods: {
			//点击警告
			warning(){
				uni.redirectTo({
				url:'../allwell_warnings/warnings',
				success:res =>{
					console.log("成功");
				},
				fail:(err) =>{
					console.log("失败");
					console.log(err);
					},
				complete:() => {},
				})
			},
			//点击所有井
			allwell(){
				uni.redirectTo({
				url:'../allwell_warnings/allwell',
				success:res =>{
					console.log("成功");
				},
				fail:(err) =>{
					console.log("失败");
					console.log(err);
					},
				complete:() => {},
				})
			},
			//退出登录
			dropout(){
				//console.log("退出登录进来没");
				const token = uni.getStorageSync('Authorization') 
				//console.log(token);
				uni.removeStorageSync('Authorization')
				uni.redirectTo({
				url:'./log',
				success:res =>{
					console.log("成功");
				},
				fail:(err) =>{
					console.log("失败");
					console.log(err);
					},
				complete:() => {},
				})
			},
			inputWell(e){
				console.log(e);
				this.texts=[]
				let wellList = []
				//let url = this.headerUrl.local+'9011/app/app/list1?jmjh='+e.detail.value+"&dwId="+this.searchValue.orgId+"&ptId="+this.searchValue.ptId+'&gylx=82640297-49ba-4042-86a4-a70e6d8a1372'
				let url = this.$requestUrl.requestUrl('/zs')+'/app/app/list1?jmjh='+e.detail.value+"&dwId="+this.searchValue.orgId+"&ptId="+this.searchValue.ptId+'&gylx=82640297-49ba-4042-86a4-a70e6d8a1372'
				//let url = '9011/app/app/list1?jmjh='+e.detail.value+"&dwId="+this.searchValue.orgId+"&ptId="+this.searchValue.ptId+'&gylx=82640297-49ba-4042-86a4-a70e6d8a1372'
				
				let data={};
				let that=this;
				this.$api.register(url,data,'GET').then(res => {
						// 成功的操作
						let data1=[]
						 data1 = res.data
						for (var i = 0; i < data1.length; i++) {
							let obj = {}
							obj.orgId = data1[i].id
							obj.name = data1[i].jmjh
							//工艺类型
							obj.dictName=data1[i].DICT_NAME;
							//单位
							obj.orgName=data1[i].ORG_NAME;
							//状态
							obj.status=data1[i].status;
							wellList[i] = obj
						}
						this.texts=wellList
						this.inputWell2(e);
						}).catch(err => {
							console.log("nnnnnnnnn");
						// 失败的操作
						})
			},
			inputWell2(e){
				let url = this.$requestUrl.requestUrl('/zs')+'/app/app/list?jmjh='+e.detail.value+"&dwId="+this.searchValue.orgId+"&ptId="+this.searchValue.ptId+'&gylx=82640297-49ba-4042-86a4-a70e6d8a1372'
				//let url = '9011/app/app/list?jmjh='+e.detail.value+"&dwId="+this.searchValue.orgId+"&ptId="+this.searchValue.ptId+'&gylx=82640297-49ba-4042-86a4-a70e6d8a1372'
				let data={};
				let that=this;
				this.$api.register(url,data,'GET').then(res => {
							if(this.texts.length === res.data.length){
								//console.log("相同不——————————————输入");
								let data1=[]
								data1 = res.data
								this.texts=[]
								let wellList = []
								for (var i = 0; i < data1.length; i++) {
								let obj = {}
								obj.orgId = data1[i].id
								obj.name = data1[i].jmjh
								//工艺类型
								obj.dictName=data1[i].DICT_NAME;
								//单位
								obj.orgName=data1[i].ORG_NAME;
								//状态
								obj.status=data1[i].status;
								wellList[i] = obj
								}
								this.texts=wellList
							}
								}).catch(err => {
									console.log("nnnnnnnnn");
								// 失败的操作
								})
			},
			clickDW(){
				_self.pickerClike = ture;
			},
			dwChange:function(e){
				this.searchValue.orgId = e.orgId
				//console.log("单位");
				this.getPtList()
				//加载单位的所以井号（没调用了拍数据库）
				this.getWellList();
				//调用了拍数据库渲染
				//this.getWellList1();
			},
			ptChange:function(e){
				this.searchValue.ptId = e.orgId
				//加载单位的所以井号（没调用了拍数据库）
				this.getWellList();
				//调用了拍数据库渲染
				//this.getWellList1();
			},
			wellChange:function(e){
				let id = e.orgId
				let jmjh = e.name
				uni.navigateTo({
					//关闭当前页面，跳转到应用内的某个页面。
					url:'../chart/zschart?well_id='+id+'&well_name='+jmjh
				});
			},
			//查询有多少单位
			getUnit(){
				let url =this.$requestUrl.requestUrl('/zs')+'/app/app/dw'
				//let url ='9011/app/app/dw'
				
				let data={};
				let that=this;
				this.$api.register(url,data,'GET').then(res => {
						// 成功的操作
						res.data.forEach((item,index)=>{
							let obj={};
							obj.name=item.orgName;
							obj.orgId=item.id;
							this.unit.push(obj);
						})
						
						}).catch(err => {
							console.log("nnnnnnnnn");
						// 失败的操作
						})
			},
			//查询平台
			getPtList(){
				this.ptList = []
				let url =this.$requestUrl.requestUrl('/zs')+'/app/app/pt?orgId='+this.searchValue.orgId;
				let data={};
				let that=this;
				this.$api.register(url,data,'GET').then(res => {
						// 成功的操作
						res.data.forEach((item,index)=>{
							let obj={};
							obj.name=item.tname;
							obj.orgId=item.id;
							this.ptList.push(obj);
						})
						
						}).catch(err => {
							console.log("nnnnnnnnn");
						// 失败的操作
						})
			},
			getWellList(){
				this.texts=[]
				this.wellList = []
				let data={};
				let that=this;
				//console.log("调这个方法没");
				let url=this.$requestUrl.requestUrl('/zs')+'/app/app/list1?gylx='+this.searchValue2.pylx;
				//let url='9011/app/app/list1?gylx='+this.searchValue2.pylx;
				
				if(this.searchValue.orgId !== ''){
					//this.searchValue2.dwId=this.searchValue.orgId,
					url=url+'&dwId='+this.searchValue.orgId
					
				}
				 if(this.searchValue.ptId !== ''){
					url += '&ptId=' + this.searchValue.ptId
					//console.log(url);
				} 
				this.$api.register(url,data,'GET').then(res => {
						// 成功的操作
							res.data.forEach((item,index)=>{
								let obj={};
								obj.name=item.jmjh;
								obj.orgId=item.id;
								//工艺类型
								obj.dictName=item.DICT_NAME;
								//单位
								obj.orgName=item.ORG_NAME;
								//状态
								obj.status=item.status;
								this.wellList.push(obj);
							})
							this.texts=this.wellList;
							this.getWellList1();
						}).catch(err => {
							console.log("nnnnnnnnn");
						// 失败的操作
						})
			},
			getWellList1(){
				//let url=this.headerUrl.local+'9011/app/app/list?gylx='+this.searchValue2.pylx;
				let url=this.$requestUrl.requestUrl('/zs')+'/app/app/list?gylx='+this.searchValue2.pylx;
				if(this.searchValue.orgId !== ''){
					//this.searchValue2.dwId=this.searchValue.orgId,
					url=url+'&dwId='+this.searchValue.orgId
				}
				 if(this.searchValue.ptId !== ''){
					url += '&ptId=' + this.searchValue.ptId
				} 
				let data={};
				let that=this;
				/* console.log("mmmmmmmm");
				console.log(url); */
				this.$api.register(url,data,'GET').then(res => {
						// 成功的操作
							if(this.texts.length === res.data.length){
								this.texts=[]
								this.wellList = [] 
								res.data.forEach((item,index)=>{
								let obj={};
								obj.name=item.jmjh;
								obj.orgId=item.id;
								//工艺类型
								obj.dictName=item.DICT_NAME;
								//单位
								obj.orgName=item.ORG_NAME;
								//状态
								obj.status=item.status;
								this.wellList.push(obj);
							})
							this.texts=this.wellList;
							}
						}).catch(err => {
							console.log("nnnnnnnnn");
						// 失败的操作
						})
			},
			//查询有多少井
			getWellNumber(){
				let url = this.$requestUrl.requestUrl('/zs')+'/app/app/wellNumber'
				//let url = '9011/app/app/wellNumber'
				
				let data={};
				let that=this;
				this.$api.register(url,data,'GET').then(res => {
						// 成功的操作
							this.wellNumber=res.data
						}).catch(err => {
							console.log("nnnnnnnnn");
						// 失败的操作
						})
				/* uni.request({
					url: url,
					data:{	
					},
					method: 'GET',
					success: res => {
						this.wellNumber=res.data
						console.log(res.data)
					},		
				}); */
			},
			//查询有多少预警
			getWarningNumber(){
				let url = this.$requestUrl.requestUrl('/zs')+'/app/app/warningTotal'
				//let url = '9011/app/app/warningTotal'
				
				let data={};
				let that=this;
				this.$api.register(url,data,'GET').then(res => {
						// 成功的操作
							this.warningNumber=res.data
						}).catch(err => {
							console.log("nnnnnnnnn");
						// 失败的操作
						})
				/* uni.request({
					url: url,
					data:{	
					},
					method: 'GET',
					success: res => {
						this.warningNumber=res.data
						
					},		
				}); */
			}
		}
	}
</script>
<style>
	
	.flex-item-A {
		width: 60px;
		
		
		margin-left: 24px;
	
		background:#fff;

		text-align: left;
	}
	.flex-item-B{
		width: 60px;
		
		text-align: left;
		background:#fff;
		margin-left: 54px;
	
	}
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.content-B {
		display: -webkit-flex;
		-webkit-align-items: center;
		align-items: center;
	}
	
	.logo {
		height: 32px;
		width: 32px;
		display: inline-block;
		
	}
	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		width: 90%;
		margin-top: 10px;
		margin-bottom: 30px;
	}
	
	.uni-name{
		width: 50px;
		height: 22px;
		font-size: 14px;
		font-weight: bold;
		color: #424242;
		line-height: 22px;
		border-radius: 0px 0px 0px 0px;
		opacity: 1;
		margin-left: 0px;
		margin-top: 0px;
	}
	.uni-names2{
		width: 50px;
		height: 22px;
		font-size: 14px;
		font-weight: bold;
		color: #424242;
		line-height: 22px;
		margin-left:30px;
	}
	 .uni-names3{
		width: 80px;
		height: 22px;
		font-size: 14px;
		font-weight: bold;
		color: #424242;
		line-height: 22px;
		margin-left: 30px;
	}
	.uni-names4{
		width: 80px;
		height: 22px;
		font-size: 14px;
		font-weight: bold;
		color: #424242;
		line-height: 22px;
		margin-left: 30px;
	}
	.uni-name-B{
		font-size: 36rpx;
		color: #565658;
		width: 33%;
		display: flex;
		justify-content: center;
		border-bottom: solid 1rpx;
	}
	
	.uni-example{
		width: 70px;
		font-size: 14px;
		font-weight: 400;
		color: #727272;
		margin-left: 10px;
		margin-top: 10px;
	}
	.uni-example1{
		width: 70px;
		font-size: 14px;
		font-weight: 400;
		color: #727272;
		margin-left: 0px;
		margin-top: 10px;
		display: block;
		margin: auto;
	}
	.uni-example2{
		width: 50px;
		font-size: 14px;
		font-weight: 400;
		color: #727272;
		margin-left: 0px;
		margin-top: 0px;
		display: block;
		margin: auto;
	}
	
	.uni-list-cell-db{
		background-color: #F6F1EF;
		width: 82.5%;
		height: 35.5px;
		border-radius: 10rpx;
		
	}
	.uni-input {
		
		justify-content: center;
		margin-top: 5px;
		margin-left: 25rpx;
		font-size: 14px;
		
		
		flex: 1;
		
	}
	.uni-input-normal{
		padding-top: 10rpx;
		padding-bottom: 10rpx;
		width: 80%;
		height: 50rpx;
		justify-content: center;
		line-height:20rpx;
		font-size:28rpx;
		background:#FFF;
		flex: 1;
		border-radius: 10rpx;
		margin-top: 20rpx;
	}
	.uni-list-cell {
		margin-top: 3%;
		height: 30px;
		width: 90%;
		position: relative;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 8px;
	}
	.uni-list-cell-left {
		width: 0%;
	    white-space: nowrap;
		font-size:28rpx;
		padding: 0 10rpx;
		text-align: right;
		font-size: 13px;
		font-weight: bold;
		color: #424242;
	}
	
	.uni-yj{
		
		width: 90%;
		height: 80px;
		-moz-box-shadow:0 0 10px #bcbcbc;
		-webkit-box-shadow:0 0 10px #bcbcbc;
		box-shadow:0 0 10px #bcbcbc;
		border-radius: 10rpx;
		margin-bottom: 24px;
		background-image: url(../../static/bj.png);
	}
	.uni-text1{
		width: 100%;
		height: 15px;
		text-align: left;
		font-size: 13px;
		font-weight: bold;
		color: #C3BEBA;
		margin-top: 10px;
		
	}
	.uni-text2{
		height: 44px;
		width: 60px;
		text-align: left;
		
		color: #424242;
		font-weight: bolder;
		font-size: 20px;

		font-weight: bold;
		padding-top: 10px;
	}
	.uni-text3{
		height: 44px;
		width: 60px;
		text-align: left;
		color: #ff0000;
		font-weight: bolder;
		font-size: 20px;
		font-weight: bold;
		padding-top: 10px;
	}
	
	.uni-botton1{
		margin-top: 20rpx;
		margin-bottom: 50rpx;
	}
	.text-input{
		text-align: left;
		margin-left: 12px;
		margin-top: 5px;
	}
	.dj-A{
		width: 4px;
		height: 20px;
		background: #F09B00;
		border-radius: 0px 0px 0px 0px;
		opacity: 1;
	}
	.dj-B{
		width: 90%;
	}
	.uni-dj-text{
		height: 40px;
		width: 88%;
		margin-left:25px;
		background: #F6F1EF;
		border-radius: 4px;
		margin-bottom: 8px;
		
	}
	.title-text{
		width: 220px;
		height: 24px;
		font-size: 18px;
		font-family: Microsoft YaHei-Bold, Microsoft YaHei;
		font-weight: bold;
		color: #424242;
		line-height: 24px;
		margin-left: 10px;
		margin-bottom:5px ;
	}
	/* 滚动加载 */
	
		.scroll-Y {
			height: 600rpx;
		}
		.scroll-view_H {
			white-space: nowrap;
			width: 100%;
		}
		.scroll-view-item {
			height: 300rpx;
			line-height: 300rpx;
			text-align: center;
			font-size: 36rpx;
		}
		.scroll-view-item_H {
			display: inline-block;
			width: 80%;
			height: 300rpx;
			line-height: 300rpx;
			text-align: center;
			font-size: 36rpx;
		}
		.drop-out {
			font-size: 23rpx;
			color: #ffaa7f;
			display: flex;
			flex-direction: column;
			align-items: center;
			padding-top: 0.2cm;
			padding-left:9.5cm;
		}
		.txzc22{
		    width:25px;
		    height:20px;
		    border-radius:50%;
		    background-color:#42b983;
		    display: block;
		    margin: auto;
			
		  }
		  .txbzc22{
		      width:25px;
		      height:20px;
		      border-radius:50%;
		      background-color: #ff3f36;
		      display: block;
		      margin: auto;
		    }

</style>
